package com.atguigu.gulimall.search.controller;

import lombok.SneakyThrows;

/**
 * @author 薛剑
 * @date 2020-11-13 11:09
 */
public class TestValiter  {




    public static void main(String[] args) {
        TestValiter  testValiter = new TestValiter();

       // new Thread(testValiter,"AAA").start();
        MyData myData = new MyData();
        new Thread(()->{
            System.out.println(Thread.currentThread().getName()+"当前线程");
            try {
                Thread.sleep(300);
                myData.setmynum();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"AAA").start();


        while (myData.num == 0) {

        }
        System.out.println(Thread.currentThread().getName()+"main");
    }


}


class MyData{

   public volatile int num=0;

    public void setmynum()
    {

        this.num = 66;
    }


}